package test.netty.server;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelOutboundHandlerAdapter;
import io.netty.channel.ChannelPromise;
import io.netty.handler.codec.http.FullHttpResponse;
import io.netty.handler.codec.http.HttpHeaderNames;

public class HttpResponseFrameHandler extends ChannelOutboundHandlerAdapter {
    @Override
    public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) {
        if(msg instanceof FullHttpResponse){
            ((FullHttpResponse) msg).headers().set(HttpHeaderNames.SEC_WEBSOCKET_PROTOCOL, "piggy");
        }
        ctx.write(msg, promise);
    }
}
